in_node_exporter: more pluggable structure#8077
Merged
edsiper merged 1 commit intofluent:masterfrom Nov 4, 2023
Merged
Conversation
Contributor
Author
How to add new collector
1. Create common sourcee.g. #ifdef __linux__
#include "ne_new_linux.c"
#elif __APPLE__
#include "ne_new_darwin.c"
#else
/* Not supported */
struct flb_ne_collector new_collector = {
.name = "new",
.cb_init = NULL,
.cb_update = NULL,
.cb_exit = NULL
};
#endif2. Create common header#ifndef FLB_IN_NE_NEW_H
#define FLB_IN_NE_NEW_H
#include "ne.h"
extern struct flb_ne_collector new_collector;
#endif4. Add mk_list_addne.c: mk_list_add(&systemd_collector._head, &ctx->collectors);
mk_list_add(&processes_collector._head, &ctx->collectors);
mk_list_add(&new_collector._head, &ctx->collectors); // add here !
mk_list_foreach(head, &ctx->collectors) {
coll = mk_list_entry(head, struct flb_ne_collector, _head);
collectors_common_init(coll);
}5. Define config mapProperty name should be ne.c: {
FLB_CONFIG_MAP_TIME, "collector.new.scrape_interval", "0",
0, FLB_FALSE, 0,
"scrape interval to collect new metrics from the node."
},
Modify plugins/in_node_exporter_metrics/CMakeLists.txt to add |
85aa10b to
38fa888
Compare
38fa888 to
17dc64e
Compare
Signed-off-by: Takahiro Yamashita <nokute78@gmail.com>
17dc64e to
a150551
Compare
cosmo0920
reviewed
Oct 23, 2023
Contributor
cosmo0920
left a comment
There was a problem hiding this comment.
It would be really good to have! I love this patch.
I confirmed that this patch does not have any side effect on macOS. Everything is working as expected.
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This patch is make more pluggable structure.
It is to remove similar codes for maintainability.
flb_ne_collectorne_filefd.[ch],ne_stat.[ch]andne_vmstat.[ch]ne_systemd.[ch]->ne_systemd_linux.[ch].struct flb_ne_collector
This struct represents common collector like plugin instance.
cpufreqcollector.%name%.scrape_intervalis defined on config map, this value is set by the value of config map. Default :scrape_intervalflb_input_set_collector_timeEnter
[N/A]in the box, if an item is not applicable to your change.Testing
Before we can approve your change; please submit the following in a comment:
If this is a change to packaging of containers or native binaries then please confirm it works for all targets.
ok-package-testlabel to test for all targets (requires maintainer to do).Documentation
Backporting
Configuration
Debug/Valgrind output
Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.